package com.googlecode.rjm.model;

import java.util.List;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

@Entity
@Table(name = "projects")
public class Project extends Persistent implements Comparable<Project> {

	private static final long serialVersionUID = 8800097305070889875L;

	@Id
	private Integer id;

	private String name;

	private String identifier;

	private String description;

	@OneToMany(mappedBy = "project")
	@OrderBy(value = "name")
	private List<Version> versions;
	
	@OneToMany(mappedBy = "project")
	private List<Member> members;

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getIdentifier() {
		return identifier;
	}

	public void setIdentifier(String indentifier) {
		this.identifier = indentifier;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public List<Version> getVersions() {
		return this.versions;
	}

	public void setVersions(List<Version> versions) {
		this.versions = versions;
	}

	public List<Member> getMembers() {
		return this.members;
	}

	public void setMembers(List<Member> members) {
		this.members = members;
	}

	public String toString() {
		return this.getName() + " (" + this.getIdentifier() + ")";
	}

	public int compareTo(Project o) {
		return this.toString().compareTo(o.toString());
	}
}
